execute.js
execute.js
is configuration of JavaScript logic when action is executed.
With predefined variables, user can create their own logic for action.
Example execute.js
try {
const message_data = {
"to": input.data.to,
"cc": input.data.cc || [],
"bcc": input.data.bcc || [],
"from": input.data.from_name ? await service.fn.string_to_qp({ "string": `${input.data.from_name} <${input.data.from}>` }) : input.data.from || "",
"subject": await service.fn.string_to_qp({ "string": input.data.subject }),
"body": input.data.body,
"bodyType": (input.data.signature || input.data.bodyType === "html") ? "html" : "plain",
"signature": input.data.signature || ""
}
const response = await $.axios({
method: "post",
url: `https://www.googleapis.com/gmail/v1/users/me/messages/send`,
headers: {
"Authorization": `Bearer ${service.token}`,
"Content-Type": "application/json"
},
data: {
"raw": await service.fn.create_raw_message(message_data),
"labelIds": input.data.labelIds || []
}
})
const email_info = await service.fn.get_email_info({ "id": response.data.id, "service_token": service.token }, $)
email_info["message_info"] = await service.fn.get_payload_info(email_info.payload)
return email_info
} catch (error) {
throw error
}
Helpful?